<?php
/*
 * @Author: 李明
 * @Date: 2021-12-10 17:53:11
 * @LastEditTime: 2021-12-20 11:37:38
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Http/Controllers/app/banner/BannerController.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Controllers\app\banner;

use App\Http\Controllers\common\LMReturn;
use App\Http\Controllers\Controller;
use App\Models\Banner;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class BannerController extends Controller
{
    /**
     * @description: 查询banner
     * @param {Request} $request
     * @return {*}
     */
    public function bannerQuery(Request $request)
    {
        // 接参
        try {
            $all = $request->all();
            $size = $all['size'] ?? 15;
            $type = $all['type'] ?? 1;
            $jump_type = $all['jump_type'] ?? '';
        } catch (\Throwable $th) {
            return LMReturn::Error("接参时发生问题", 'BCBQ01');
        }

        try {
            $where = [];
            if ($type != '') {
                $where[] =  ['type', $type];
            }
            if ($jump_type != '') {
                $where[] =  ['jump_type', $jump_type];
            }
            $banner_list = Banner::where($where)->paginate($size);
            return LMReturn::Success($banner_list);
        } catch (\Throwable $th) {
            return LMReturn::Error("查询时发生问题", 'BCBQ02');
        }
    }
}
